﻿@model List<LynxWiki.ViewModels.WikiTopicHistoryListingViewData>

@using LynxWiki.ViewModels;

@{
    ViewBag.Title = Model[0].TopicName + "History";
    Layout = "~/Views/Shared/_LayoutTopic.cshtml";
}

<h2>@Model[0].TopicName - History</h2>
<table class="TableClass">
    <tr>
        <th class="TableCellHighlighted">Date Time Created</th><th class="TableCellHighlighted">Ver</th><th class="TableCellHighlighted">Creator</th><th colspan="3">Actions</th>
    </tr>
    @foreach (WikiTopicHistoryListingViewData lvd in Model) {
      <tr>
        <td class="TableCell">@lvd.CreatedOn</td>
        <td class="TableCell">@lvd.Version</td>
        <td class="TableCell">@lvd.Creator</td>
        <td class="TableCell">
        @using (Html.BeginForm("TopicHistory", "WikiTopic", FormMethod.Post, new { @class = "frmTopicHistory", id = lvd.TopicName + lvd.Version })) {
            @Html.Hidden("TopicName", lvd.TopicName)
            @Html.Hidden("Version", lvd.Version)
            @Html.Hidden("WikiDir", lvd.WikiDir)
            @Html.Hidden("TopicBody", lvd.TopicBody)
            <input type="submit" name="btnPreview" class="btnPreview" value="Preview" />
        }</td>
        <td class="TableCell">
        @using (Html.BeginForm("TopicHistory", "WikiTopic", FormMethod.Post, new { @class = "frmMakeCurrent", id = lvd.TopicName + lvd.Version })) {
            @Html.Hidden("TopicName", lvd.TopicName)
            @Html.Hidden("Version", lvd.Version)
            @Html.Hidden("WikiDir", lvd.WikiDir)
            <input type="submit" name="btnMakeCurrent" class="btnMakeCurrent" value="Make Current" />
        }</td>
        <td class="TableCell">
        @using (Html.BeginForm("TopicHistory", "WikiTopic", FormMethod.Post, new { @class = "frmShowDir", id = lvd.TopicName + lvd.Version })) {
            @Html.Hidden("TopicName", lvd.TopicName)
            @Html.Hidden("Version", lvd.Version)
            @Html.Hidden("WikiDir", lvd.WikiDir)
            @Html.DropDownList("diffVersion", new SelectList(Model, "Version", "CreatedOn"))
            <input type="submit" name="btnShowDiff" class="btnShowDiff" value="Show Difference" />
        }</td>
    </tr>
    }
</table>

@section Scripts {
    <script type="text/javascript" >
        $(document).ready(function () {
            $(".btnPreview").click(function (e) {
                $(".frmTopicHistory").attr("target", "_blank");
                return true;
            });
            $(".btnShowDiff").click(function (e) {
                $(".frmShowDir").attr("target", "_blank");
                return true;
            });
            $(".btnMakeCurrent").click(function (e) {
                $(".frmMakeCurrent").attr("target", "_self");
                return true;
            });
        });
    </script>
}